Skip to content

Birmingham | 2026-MAR-SDC | Joy Opachavalit | Sprint 2 | jq#379

Open
enjoy15 wants to merge 1 commit intoCodeYourFuture:mainfrom
enjoy15:jq
Open

Birmingham | 2026-MAR-SDC | Joy Opachavalit | Sprint 2 | jq#379
enjoy15 wants to merge 1 commit intoCodeYourFuture:mainfrom
enjoy15:jq

Conversation

@enjoy15
Copy link
Copy Markdown

@enjoy15 enjoy15 commented Mar 15, 2026

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Completed all exercises

@enjoy15 enjoy15 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 15, 2026
@github-actions

This comment has been minimized.

@enjoy15 enjoy15 changed the title Birmingham | 2026-MAR-SDC | Joy Opachavalit | Sprint 1 | jq Birmingham | 2026-MAR-SDC | Joy Opachavalit | Sprint 2 | jq Mar 15, 2026
@enjoy15 enjoy15 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 2 Assigned during Sprint 2 of this module Module-Tools The name of the module. labels Mar 15, 2026
Copy link
Copy Markdown

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solution looks good. I just have a question.

Comment thread jq/script-11.sh
# The input for this script is the scores.json file.
# TODO: Write a command to output the total of adding together all scores from all games from all players.
# Your output should be exactly the number 164.
jq -r 'map(.scores) | add | add' scores.json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain how the two add works in the query? That is, why "add" twice?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Data shape: scores.json is an array of player objects where each scores value is an array (e.g. [[1,10,4],[22,9,6],...]).
map(.scores) produces an array of arrays: [[1,10,4],[22,9,6],...].
First add: when add is given an array of arrays it concatenates them into one array: [1,10,4,22,9,6,...].
Second add: when add is given an array of numbers it returns their sum (i.e. 164).
So map(.scores) | add | add is: collect each player's scores then join into one big list then sum the numbers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good. Well done.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels May 9, 2026
@enjoy15 enjoy15 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label May 10, 2026
@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. labels May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Tools The name of the module. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants